/*
 ============================================================================
 Page	     : 449-450
 Name        : friends.c
 Date	     : 20210407
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 使用指向结构的指针
 ============================================================================
 */

#include <stdio.h>
#define LEN 20

struct names
{
	char first[LEN];
	char last[LEN];
};

struct guy
{
	struct names handle;
	char favfood[LEN];
	char job[LEN];
	float income;
};

int main(void)
{
	struct guy fellow[2] = {		// 初始化一个结构变量
			{ { "Ewen", "Villard" },
				"grilled salmon",
				"personality coach",
				68112.00
			},
			{ { "Rodney", "Swillbelly"},
				"tripe",
				"tabloid editor",
				432400.0
			}
	};

	struct guy * him;			/* 这是一个指向结构的指针 */

	printf("address #1: %p #2: %p\n", &fellow[1], &fellow[2]);
	him = &fellow[0];			/* 告诉编译器指针指向何处 */
	printf("pointer #1: %p #2: %p\n", him, him + 1);
	printf("him->income is $%.2f: (*him).income is $%.2f\n", him->income, (*him).income);
	him++;						/* 指向下一个结构 */
	printf("him->favfood is %s: him->handle.last is %s\n", him->favfood, him->handle.last);
	return 0;
}

